package fun.boomcat.luckyhe.mirai.plugin.botcontrol.util;

import net.mamoe.mirai.event.events.BotInvitedJoinGroupRequestEvent;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Lucky_He
 * @date 2021年8月26日 17:22
 * @description BotInvitedJoinGroupRequestEventUtil
 */
public class BotInvitedJoinGroupRequestEventUtil {
    private static List<BotInvitedJoinGroupRequestEvent> events = new ArrayList<>();

    public static void insert(BotInvitedJoinGroupRequestEvent event) {
        events.add(event);
    }

    public static void remove(BotInvitedJoinGroupRequestEvent event) {
        events.remove(event);
    }

    public static BotInvitedJoinGroupRequestEvent get(long eventId) throws Exception {
        for (BotInvitedJoinGroupRequestEvent event : events) {
            if (event.getEventId() == eventId) {
                return event;
            }
        }

        throw new Exception("未找到事件号为" + eventId + "的邀请进群事件");
    }

    public static List<BotInvitedJoinGroupRequestEvent> getEvents() {
        return events;
    }
}
